let express = require('express');
let app = express();
// 引入
let session = require('express-session');
// 引入路由
let indexRouter = require('./router/indexRouter');
let userRouter = require('./router/userRouter');
let articleRouter = require('./router/articleRouter');

let bodyParser = require('body-parser');
// 使用express-session中间件
app.use(session({
    secret: 'itcast',
    resave: false,
    saveUninitialized: true
}))
app.set('view engine', 'ejs');
app.set('views', './views');
// app.user()设置静态资源托管的时候，第一个参数始终是绝对路径
// 第二个参数始终是相对路径
app.use('/node_modules', express.static('./node_modules'));

app.use(bodyParser.urlencoded({ extended: false }));

app.use(bodyParser.json());
app.use(indexRouter);
app.use(userRouter);

app.use(articleRouter);

app.listen(3001, () => {
    console.log("端口号为：3001");
})